import { ApiProperty } from '@nestjs/swagger';
import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  ManyToOne,
  UpdateDateColumn,
  JoinColumn,
} from 'typeorm';
import { ChatUser } from '../../chat_user/entities/chat_user.entity';

/*
 * @Description:
 * @Author: fhw
 * @Date: 2022-08-08 16:22:48
 */
@Entity('sys_message')
export class SysMessage {
  @ApiProperty({ example: 'id', description: 'id' })
  @PrimaryGeneratedColumn({
    type: 'int',
    comment: 'id',
  })
  id: number;

  @ApiProperty({ example: 'message_title', description: '消息标题' })
  @Column({
    type: 'varchar',
    length: 100,
    comment: '消息标题',
  })
  message_title: string;

  @ApiProperty({ example: 'message_content', description: '消息内容' })
  @Column({
    type: 'varchar',
    comment: '消息内容',
  })
  message_content: string;

  @ApiProperty({
    example: 'message_type',
    description: '消息类型，1:好友验证通知, 2：群聊消息',
  })
  @Column({
    type: 'tinyint',
    comment: '消息类型，1:好友验证通知, 2：群聊消息',
  })
  message_type: number;

  @ApiProperty({
    example: 'message_status',
    description: '消息状态，0：未读，1已读',
  })
  @Column({
    type: 'tinyint',
    comment: '消息状态，0：未读，1已读',
    default: 0,
  })
  message_status: number;

  @ApiProperty({ example: 'date', description: '创建时间' })
  @CreateDateColumn({
    type: 'datetime',
    comment: '创建时间',
  })
  createDate: string;

  @ApiProperty({ example: 'updateDate', description: '更新时间' })
  @UpdateDateColumn({
    type: 'datetime',
    comment: '更新时间',
  })
  updateDate: string;

  @ApiProperty({ example: 'status', description: '状态' })
  @Column({
    type: 'int',
    comment: '好友验证状态:0：拒绝，1通过，2：作废',
    default: 0,
  })
  status: number;

  @ApiProperty({ example: 'createdId', description: '创建人id' })
  @Column({
    type: 'int',
    comment: '创建人id',
  })
  createdId: number;

  @ManyToOne(() => ChatUser, (m) => m.id)
  created: ChatUser;

  @ApiProperty({ example: 'toUserId', description: '推送用户id' })
  @Column({
    type: 'int',
    comment: '推送用户id',
  })
  toUserId: number;

  @ApiProperty({ example: 'toUser', description: '推送用户id' })
  @ManyToOne(() => ChatUser, (m) => m.id)
  @JoinColumn()
  toUser: ChatUser;


  @ApiProperty({ example: 'created_by', description: '创建人' })
  @Column({
    type: 'varchar',
    comment: '创建人',
    nullable: true,
  })
  createdName: string;
}
